package Java实验.实验二;
public class Demo4 {
    public void dayCount(int year, int month, int day) {
        /********** Begin *********/
        int result=0;
        if(month==5||month==6){
            result-=1;
        }else if(month==7||month==8){
            result-=2;
        }else if(month==9||month==10||month==11){
            result-=3;
        }else if(month==12){
            result-=4;
        }

        switch(month){
            case 1:
            case 2:
                for(int i=1;i<month;i++){
                    result+=31;
                }
                result+=day;
                break;
            case 3:
            case 4:
            case 5:
            case 6:
            case 7:
            case 8:
            case 9:
            case 10:
            case 11:
            case 12:
                if((year%4==0&&year%100!=0)||year%400==0){
                    for(int i=2;i<month;i++){
                        result+=31;
                    }
                    result+=29+day;
                    break;
                }else{
                    for(int i=2;i<month;i++){
                        result+=31;
                    }
                    result+=28+day;
                }
                break;
        }
        System.out.println(result);
        /********** End *********/
    }
    public static void main(String[] args){
        Demo4 d4 = new Demo4();
        d4.dayCount(2020,3,1);
        d4.dayCount(2022,3,1);
        d4.dayCount(2000,5,2);
    }
}
